/*
 serialStreamer
 
 This example shows how to fade an LED on pin 9
 using the analogWrite() function based on a value
 read from analog pin 0.
 
 Analog pin 0 is read and streamed as fast as 
 possible over the serial port.
  
 This example code is in the public domain.
 
 */
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by
int sensorValue = 0;
int sensorPin = 0;

void setup()  { 
  // declare pin 9 to be an output:
  pinMode(9, OUTPUT);
  Serial.begin(9600); 

} 

void loop()  { 
  sensorValue = analogRead(sensorPin);    
  
  brightness = map(sensorValue, 0, 1023, 0, 255);

  // set the brightness of pin 9:
  analogWrite(9, 255-brightness); 
               
  Serial.println( sensorValue );
}
